<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Riverside Anywhere 选项</title>
<style type="text/css">
body {
	margin: 0 auto;
	width: 800px;
	font-family: helvetica, arial, sans-serif;
}
#header {
	margin-top: 1em;
}
#logo {
	vertical-align: bottom;
}
#title {
	font-weight: bold;
	font-size: large;
}
.section-header {
	margin-top: 0.5em;
	padding-top: 3px;
	padding-bottom: 2px;
	padding-left: 5px;
	padding-right: 0px;
	background-color: #EBEFF9;
	font-weight: bold;
	font-size: small;
}
.section-content {
	margin-top: 1em;
	margin-bottom: 1em;
	padding-left: 5px;
	font-size: small;
}
.option-name {
	margin-top: 1em;
	margin-bottom: 5px;
	font-weight: bold;
}
#get-msg-interval-alert {
	font-weight: bold;
	color: red;
}
#footer {
	margin-top: 1em;
}
.foot-text {
	font-size: small;
	padding-left: 5px;
}
hr {
	width: 300px;
	text-align: left;
	margin-left: 0;
}
.note {
	margin-top: 0.5em;
	font-style: italic;
	font-size: x-small;
}
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
/*
 * riverside-anywhere - a useful tool for riverside of UESTC
 * Copyright (C) 2011-2012, riverside-anywhere developers and contributors
 * Copyright (C) 2011-2012, Cohesion Network Security Studio
 *
 * riverside-anywhere is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * riverside-anywhere is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with riverside-anywhere; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

function initValue() {
	$("#in-domain select option").each(function(idx,element){
		if($(this).val() == localStorage['in_domain']) {
			$(this).attr("selected","selected");
		}
	});
	$("#out-domain select option").each(function(idx,element){
		if($(this).val() == localStorage['out_domain']) {
			$(this).attr("selected","selected");
		}
	});
	if(localStorage['auto_convert'] == 0) {
		$("input[name='auto-convert'][value='0']").attr("checked","checked");
		$("#convert-detail").hide();
	} else {
		$("input[name='auto-convert'][value='1']").attr("checked","checked");
	}
	if(localStorage['auto_detect'] == 0) {
		$("input[name='auto-detect'][value='0']").attr("checked","checked");
	} else {
		$("input[name='auto-detect'][value='1']").attr("checked","checked");
		$("#at-school").hide();
	}
	if(localStorage['at_school'] == 0) {
		$("input[name='at-school'][value='0']").attr("checked","checked");
	} else {
		$("input[name='at-school'][value='1']").attr("checked","checked");
	}
	if(localStorage['get_msg'] == 0) {
		$("input[name='get-msg'][value='0']").attr("checked","checked");
		$("#get-msg-interval").hide();
	} else {
		$("input[name='get-msg'][value='1']").attr("checked","checked");
	}
	$("input[name='get-msg-interval']").val(localStorage['get_msg_interval']);
}

$(document).ready(function(){
	initValue();

	var background = chrome.extension.getBackgroundPage();
	// bind action
	$('#in-domain select').change(function(){
		localStorage['in_domain'] = $("#in-domain select").val();
	});
	$('#out-domain select').change(function(){
		localStorage['out_domain'] = $("#out-domain select").val();
	});
	$('#auto-convert :radio').change(function(){
		$("#convert-detail").slideToggle("slow");
		localStorage['auto_convert'] = $("input[name='auto-convert']:checked").val();
	});
	$('#auto-detect :radio').change(function(){
		$("#at-school").slideToggle("slow");
		localStorage['auto_detect'] = $("input[name='auto-detect']:checked").val();
		background.autoDetect();
	});
	$('#at-school :radio').change(function(){
		localStorage['at_school'] = $("input[name='at-school']:checked").val();
	});
	$('#get-msg :radio').change(function(){
		$("#get-msg-interval").slideToggle("slow");
		localStorage['get_msg'] = $("input[name='get-msg']:checked").val();
		background.initGetMsg();
	});
	$('#get-msg-interval :input').change(function(){
		var interval = parseInt($("input[name='get-msg-interval']").val());
		if(isNaN(interval)
		|| interval < 15) {
			$("#get-msg-interval-alert").html("请输入大于15的数字！");
			return;
		} else {
			$("#get-msg-interval-alert").html("");
		}
		localStorage['get_msg_interval'] = interval;
		background.initGetMsg();
	});
});
</script>
</head>
<body>
<div id="header">
	<span id="title">Riverside Anywhere 选项</span>
</div>
<div id="content">
<div class="section-header">基本设置</div>
<div class="section-content">
	<div class="option" id="in-domain">
		<p class="option-name">内网常用域名：</p>
		<select>
			<option value="bbs.stuhome.net">bbs.stuhome.net</option>
			<option value="bbs.uestc6.edu.cn">bbs.uestc6.edu.cn</option>
		</select>
		<br />
		<div class="note">内网获取未读站内信域名</div>
	</div>
	<div class="option" id="out-domain">
		<p class="option-name">外网常用域名：</p>
		<select>
			<option value="bbs.qshpan.com">bbs.qshpan.com</option>
			<option value="bbs.germanyt.com">bbs.germanyt.com</option>
		</select>
		<br />
		<div class="note">外网获取未读站内信域名以及跳转的外网域名</div>
	</div>
</div>
<div class="section-header">域名转换设置</div>
<div class="section-content">
	<div class="option" id="auto-convert">
		<p class="option-name">自动转换域名：</p>
		<input type="radio" name="auto-convert" value="1" id="auto-convert-yes" /><label for="auto-convert-yes">开启</label>
		<input type="radio" name="auto-convert" value="0" id="auto-convert-no" /><label for="auto-convert-no">关闭</label>
	</div>
	<div id="convert-detail">
		<div class="option" id="auto-detect">
			<p class="option-name">自动检测是否在学校：</p>
			<input type="radio" name="auto-detect" value="1" id="auto-detect-yes" /><label for="auto-detect-yes">开启</label>
			<input type="radio" name="auto-detect" value="0" id="auto-detect-no" /><label for="auto-detect-no">关闭</label>
		</div>
		<div class="option" id="at-school">
			<p class="option-name">当前位置：</p>
			<input type="radio" name="at-school" value="1" id="at-school-yes" /><label for="at-school-yes">校内</label>
			<input type="radio" name="at-school" value="0" id="at-school-no" /><label for="at-school-no">校外</label>
		</div>
	</div>
</div>
<div class="section-header">站内信提醒设置</div>
<div class="section-content">
	<div class="option" id="get-msg">
		<p class="option-name">离线站内信提醒：</p>
		<input type="radio" name="get-msg" value="1" id="get-msg-yes" /><label for="get-msg-yes">开启</label>
		<input type="radio" name="get-msg" value="0" id="get-msg-no" /><label for="get-msg-no">关闭</label>
	</div>
	<div class="option" id="get-msg-interval">
		<p class="option-name">获取未读站内信个数时间间隔：</p>
		每 <input type="text" name="get-msg-interval" size="1"/> 秒获取一次 <span id="get-msg-interval-alert"></span>
		<div class="note">最小15秒</div>
	</div>
</div>
</div>
<div id="footer">
	<hr />
	<span class="foot-text">提交您对本项目的建议：<a href="http://groups.google.com/group/riverside-anywhere">Google Group</a></span>
	<br />
	<span class="foot-text">项目主页：<a href="http://code.google.com/p/riverside-anywhere/">Google Code</a></span>
</div>
</body>
</html>
